<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
		<title></title>
		<link rel="stylesheet" href="css/muse-ui.css">
		<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700,400italic">
		<link rel="stylesheet" href="https://cdn.bootcss.com/material-design-icons/3.0.1/iconfont/material-icons.css">
		<link rel="stylesheet" href="css/muse-ui-loading.css">
		<link rel="stylesheet" href="https://at.alicdn.com/t/font_951857_sr7zod4vu4.css">
		<script src="js/vue.min.js"></script>
		<script src="js/muse-ui.js"></script>
		<script src="js/muse-ui-loading.js"></script>
		<script src="js/muse-ui-toast.js"></script>
		<script src="js/axios.min.js"></script>
		<script src="js/mui.min.js"></script>
		<script src="js/utils.js"></script>
		<style>
			.container{
				height:calc(100vh);
				width: 100%;
				padding: 20px;
			}
			.container input {
				color: #ff4081;
			}
			.list-item{
				display: flex;
				line-height: 30px;
			}
			.label{
				width: 20%;
				text-align: right;
			}
			.label-value{
				margin-left: 15px;
				color: rgba(0,0,0,.5);
			}
		</style>
	</head>
	<body>
		<div id="body">
			<mu-appbar style="width: 100%;position: fixed;top: 0;padding-top: 20px;height: auto;" color="primary">
				<mu-button icon slot="left" @click="util.back()">
					<mu-icon value="arrow_back"></mu-icon>
				</mu-button>
				{{building.name}}
			</mu-appbar>
			<mu-container ref="container" style="padding-top: 76px;">
				<mu-text-field v-model="key" label-float label="业主姓名或业主编号或燃气编号" color="primary" full-width></mu-text-field>
				<mu-load-more @refresh="refresh" :refreshing="refreshing" :loading="loading" @load="load">
					<mu-list>
						<template v-for="(item,index) in list">
							<mu-paper :z-depth="2" style="padding: 15px;margin-top: 15px;" @click="goMeterRecord(item)">
								<div class="list-item">
									<div class="label">气表编号:</div>
									<div class="label-value">{{item.no}}</div>
								</div>
								<div class="list-item">
									<div class="label">气表读值:</div>
									<div class="label-value">{{item.gasConsume}}m³</div>
								</div>
								<div class="list-item">
									<div class="label">开户时间:</div>
									<div class="label-value">{{item.createDate}}</div>
								</div>
								<div class="list-item">
									<div class="label">地址:</div>
									<div class="label-value">{{item.address}}</div>
								</div>
								<div class="list-item">
									<div class="label">状态:</div>
									<div class="label-value">{{item.isEnable==1?'正常':'停用'}}</div>
								</div>
								<div class="list-item">
									<div class="label">业主:</div>
									<div class="label-value">{{item.name}}</div>
								</div>
								<div class="list-item">
									<div class="label">手机:</div>
									<div class="label-value">{{item.phone}}</div>
								</div>
							</mu-paper>
						</template>
					</mu-list>
				</mu-load-more>
			</mu-container>
		</div>
	</body>
	<script type="text/javascript">
		var vm = new Vue({
			el: "#body",
			data() {
				return {
					building: {
						name:""
					},
					list: [],
					limit: 20,
					tabindex: 0,
					refreshing: false,
					loading: false,
					key:""
				}
			},
			watch:{
				key:function (newValue,oldValue) {
					this.refresh();
				}
			},
			methods: {
				goMeterRecord(meter){
					util.setData("meter",meter)
					util.openWindow("meterRecord.html")
				},
				refresh() {
					this.refreshing = true;
					this.$refs.container.scrollTop = 0;
					var params = {
						start: 1,
						limit: this.limit,
						key:this.key,
						buildingId:this.building.id
					}
					util.ajax("/api/method/getMeterListByBuildingId", params, data => {
						this.refreshing = false;
						this.list = data.object.list;
					})
				},
				load() {
					this.loading = true;
					var params = {
						start: this.list.length,
						limit: this.limit,
						key:this.key,
						buildingId:this.building.id
					}
					util.ajax("/api/method/getMeterListByBuildingId", params, data => {
						this.loading = false;
						this.list = this.list.concat(data.object.list);
					})
				}
			}
		})
		document.addEventListener('plusready', function() {
			vm.building = util.getData("building")
			vm.refresh();
		});
	</script>
</html>
